import matplotlib.pyplot as plt
import numpy as np
import json

with open("plot/Q-value-distribution/phi3-sampling/success_q_list.json") as f:
    success_data1=json.load(f)

with open("plot/Q-value-distribution/phi3-with-q-sampling/success_q_list.json") as f:
    success_data2=json.load(f)

with open("plot/Q-value-distribution/phi3-sampling/failure_q_value_list.json") as f:
    failure_data=json.load(f)

success_data = success_data1+success_data2
# 绘制直方图
plt.hist(success_data[:200], bins=5, alpha=0.5, label='Data 1')
plt.hist(failure_data[:200], bins=5, alpha=0.5, label='Data 2')

# 设置图表属性
plt.title('RUNOOB hist() Test')
plt.xlabel('Value')
plt.ylabel('Frequency')

# 显示图表
plt.show()

# 保存图形到文件
plt.savefig('plot/histogram_with_normal_fit.png', dpi=300, bbox_inches='tight')